<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    		<form class="form-horizontal" action="/user/save" method="post" id="userForm">
		    <fieldset>
		    <div id="legend" class="">
        		<legend class="">提交用户</legend>
      		</div>
		
		
		    <div class="control-group">
					<input type="hidden" value="${member.id }" name="id">
		          <!-- Text input-->
		          <label class="control-label" for="input01">用户名：</label>
		          <div class="controls">
		            <input type="text" placeholder="" class="input-xlarge" name="username" value="${member.username }">
		            <p class="help-block"></p>
		          </div>
		        </div>
		        
				<div class="control-group">
		
		          <!-- Text input-->
		          <label class="control-label" for="input01">密码：</label>
		          <div class="controls">
		            <input type="password" placeholder="" class="input-xlarge" id="password" name="password" value="${member.password }">
		            <p class="help-block"></p>
		          </div>
		        </div>
		        
		        <div class="control-group">
		
		          <!-- Text input-->
		          <label class="control-label" for="input01">确认密码：</label>
		          <div class="controls">
		            <input type="password" placeholder="" class="input-xlarge" name="confirm_password" value="${member.password }">
		            <p class="help-block"></p>
		          </div>
		        </div>
		        
		        <div class="control-group">
		
		          <!-- Text input-->
		          <label class="control-label" for="input01">权限：</label>
		          <div class="controls">
			          		<select id="role" name="role">
							      <option value="01">管理员</option>
      						</select>
		            <p class="help-block"></p>
		          </div>
		        </div>
		        
		 	<div class="control-group">
		
		          <div class="controls">
		           
		            <button type="submit" class="btn">提交</button>
		          </div>
		        </div>
		    </fieldset>
  			</form>

<script type="text/javascript">
   $(document).ready(function() {
	   
	   
	// 用户名字符验证    
	   jQuery.validator.addMethod("userName", function(value, element) {    
	     return this.optional(element) || /^[\u0391-\uFFE5\w]+$/.test(value);    
	   }, "用户名只能包括中文字、英文字母、数字和下划线!");   

		$('#userForm').ajaxForm({
			beforeSubmit:function(){
				return $('#userForm').validate().form();
			},
			success:function(){
				$('#div_right').load("/user/manage");
			}
		});
	
	   $("#userForm").validate({
			rules: {
				username: {required:true,maxlength:16,minlength:3,userName:true},
				password: {required:true,maxlength:12,minlength:6},
				confirm_password:{required:true,equalTo:"#password"}
			},
			messages: {
				username: {required:"请填写用户名",maxlength:"您输入的字符数不能大于 16 位",minlength:"您输入的字符数不能小于 3位"},
				password: {required:"请填写密码",minlength:"最小长度:6",maxlength:"最大长度:12"},
				confirm_password:{required:"请输入确认密码",equalTo:"密码不一致"}
			}
		});

   });
</script>
